//
// Created by feng on 19-4-11.
//

/**
 * 对场景进行预处理，
 *      生成光线的SSP和MHNP----用于生成光线方向，
 *      生成Grid中的HIA和HSIA----记录Grid中每个体素中包含或相交的镜子序列，用于3D-DDA
 */

#ifndef SOLARENERGY_CHIER_SCENEPROCESSOR_H
#define SOLARENERGY_CHIER_SCENEPROCESSOR_H

#include <memory>
#include <vector>

#include <driver_types.h>

namespace solar
{
    class SceneConfiguration;
    class SceneField;
    namespace cuda
    {
        class CudaGrid;
        class CudaHeliostat;
        class CudaReceiver;
        class CudaSunray;
    } // namespace cuda

    class SceneProcessor
    {

        public:
            SceneProcessor() : sceneConfiguration(nullptr) {}

            SceneProcessor(SceneConfiguration* sceneConfigure) : sceneConfiguration(sceneConfigure)
            {
            }

            auto processScene(const std::shared_ptr<SceneField>& field) -> bool;

            auto set_grid_receiver_heliostat_content(
                std::vector<std::shared_ptr<cuda::CudaGrid>>& grids,
                std::vector<std::shared_ptr<cuda::CudaReceiver>>& receivers,
                std::vector<std::shared_ptr<cuda::CudaHeliostat>>& heliostats) -> bool;

            auto set_sunray_content(const std::shared_ptr<cuda::CudaSunray>& sunray) -> bool;

            [[nodiscard]] auto getSceneConfiguration() const -> SceneConfiguration*;

            void setSceneConfiguration(SceneConfiguration* config);
            cudaStream_t stream_;

        private:
            auto set_perturbation(cuda::CudaSunray* sunray) -> bool;
            auto set_samplelights(cuda::CudaSunray* sunray) -> bool;
            SceneConfiguration* sceneConfiguration;
    };
} // namespace solar

#endif // SOLARENERGY_CHIER_SCENEPROCESSOR_H
